package br.com.xxx.extrator.core.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class UtlCoreBc {

	
		public static String dateToStr(Date dt, String formato){
			SimpleDateFormat sdf = new SimpleDateFormat(formato);
			
			return sdf.format(dt);
		}
	
	    public static String addDiaStrToStr(String dt, String formato, int i) throws ParseException
	    {
	    	SimpleDateFormat sdf = new SimpleDateFormat(formato);
	    	Calendar c = Calendar.getInstance();
	    	c.setTime(sdf.parse(dt));
	    	c.add(Calendar.DATE, i);  
	    	return dt = sdf.format(c.getTime());
	    }
	    
	    public static Date addDiaStrToDate(String dt, String formato, int i) throws ParseException
	    {
	    	SimpleDateFormat sdf = new SimpleDateFormat(formato);
	    	Calendar c = Calendar.getInstance();
	    	c.setTime(sdf.parse(dt));
	    	c.add(Calendar.DATE, i);  
	    	return sdf.getCalendar().getTime();
	    }
	    
	    public static Date addDia(Date date, int days)
	    {
	        Calendar cal = Calendar.getInstance();
	        cal.setTime(date);
	        cal.add(Calendar.DATE, days); 
	        return cal.getTime();
	    }
	
}
